package com.xzgj.fmmall.controller;

import com.xzgj.fmmall.service.CategoryService;
import com.xzgj.fmmall.service.IndexImgService;
import com.xzgj.fmmall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/index")
@Api(value = "提供轮播图",tags = "首页管理")
public class IndexController {
    @Resource
    private IndexImgService indexImgService;
    @Resource
    private CategoryService categoryService;
    //只有一个参数时，默认为get
    @ApiOperation("首页轮播图接口")
    @GetMapping(value = "/indexImg")
    public ResultVO listIndexImgs(){
        return indexImgService.listIndexImgs();
    }

    @ApiOperation("首页分类接口")
    @GetMapping(value = "/category")
    public ResultVO listIndexCategories(){
        return categoryService.selectAllCategories();
    }

    @ApiOperation("首页分类接口_more---作用同上")
    @ApiImplicitParam(dataType = "int",name = "productId",value = "商品id",required = true,defaultValue = "1")
    @GetMapping(value = "/subCategory")
    public ResultVO subListIndexCategories(int productId){
        return categoryService.selectChildrenCategoriesByParentId(productId);
    }
}
